package cn.wolfcode.education.web.controller;

import cn.wolfcode.education.anno.PermissionName;
import cn.wolfcode.education.domain.Menu;
import cn.wolfcode.education.query.QueryObject;
import cn.wolfcode.education.service.IMenuService;
import cn.wolfcode.education.util.PageResult;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@RequestMapping("menu")
public class MenuController {
    @Autowired
    private IMenuService menuService;

    @RequestMapping("query")
    @ResponseBody
    @RequiresPermissions("menu:query")
    @PermissionName("菜单列表")
    private PageResult query(QueryObject qo) {
        return menuService.query(qo);
    }

    //查询所有菜单
    @RequestMapping("selectAllParent")
    @ResponseBody
    public List<Menu> selectAllParent() {
        return menuService.selectAllParent();
    }

    //查询首页所有菜单
    @RequestMapping("indexMenus")
    @ResponseBody
    public List<Menu> indexMenus() {
        return menuService.indexMenus();
    }

    //根据角色的id查询菜单的id集合
    @RequestMapping("listIdsByRoleId")
    @ResponseBody
    public List<Long> listIdsByRoleId(Long roleId) {
        return menuService.listIdsByRoleId(roleId);
    }


}
